package com.cty.B_AllocationAndCollection.E_HandlePromotion;

/**
 * @Auther: cty
 * @Date: 2020/6/30 20:43
 * @Description: 空间分配担保
 * @VM Args: -XX:+PrintGCDetails -Xms20m -Xmx20m -Xmn10m -XX:SurvivorRatio=8 -XX:+HandlePromotionFailure
 * @version: 1.0
 */
public class HandlePromotion {
    private static final int _1MB = 1024 * 1024;

    public static void testHandlePromotion(){
        byte[] allocation1, allocation2, allocation3, allocation4, allocation5, allocation6, allocation7;
        allocation1 = new byte[2 * _1MB];
        allocation2 = new byte[2 * _1MB];
        allocation3 = new byte[2 * _1MB];
        allocation1 = null;
        allocation4 = new byte[2 * _1MB];
        allocation5 = new byte[2 * _1MB];
        allocation6 = new byte[2 * _1MB];
        allocation4 = null;
        allocation5 = null;
        allocation6 = null;
        allocation7 = new byte[2 * _1MB];
    }

    public static void main(String[] args) {
        testHandlePromotion();
    }

}  // end class

/**
 * Java HotSpot(TM) Client VM warning: ignoring option HandlePromotionFailure; support was removed in 6.0_24
 * [GC[DefNew: 7187K->419K(9216K), 0.0031530 secs] 7187K->4515K(19456K), 0.0031923 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
 * [GC[DefNew: 6903K->417K(9216K), 0.0008136 secs] 10999K->4513K(19456K), 0.0008426 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
 * Heap
 *  def new generation   total 9216K, used 2547K [0x33a00000, 0x34400000, 0x34400000)
 *   eden space 8192K,  26% used [0x33a00000, 0x33c14828, 0x34200000)
 *   from space 1024K,  40% used [0x34200000, 0x34268718, 0x34300000)
 *   to   space 1024K,   0% used [0x34300000, 0x34300000, 0x34400000)
 *  tenured generation   total 10240K, used 4096K [0x34400000, 0x34e00000, 0x34e00000)
 *    the space 10240K,  40% used [0x34400000, 0x34800020, 0x34800200, 0x34e00000)
 *  compacting perm gen  total 12288K, used 239K [0x34e00000, 0x35a00000, 0x38e00000)
 *    the space 12288K,   1% used [0x34e00000, 0x34e3bf18, 0x34e3c000, 0x35a00000)
 *     ro space 10240K,  44% used [0x38e00000, 0x3927aee0, 0x3927b000, 0x39800000)
 *     rw space 12288K,  52% used [0x39800000, 0x39e42e10, 0x39e43000, 0x3a400000)
 */
